/* hal_efm.h */
#ifndef __HAL_EFM_H__
#define __HAL_EFM_H__

#include "hal_common.h"

void EFM_EnablePrefetch(EFM_Type * base, bool enable);
void EFM_SetWaitReadStateDiv(EFM_Type * base, uint32_t div);

/* status flags. */
#define EFM_FLAG_CMD_DONE      EFM_STS_DONE_MASK
#define EFM_FLAG_RECOVER_ERR   EFM_STS_RECOVERR_MASK   /* 1-bit ecc error. */
#define EFM_FLAG_UNRECOVER_ERR EFM_STS_UNRECOVERR_MASK /* 2-bit ecc error. */
#define EFM_FLAG_ACCESS_ERR    EFM_STS_ACCERR_MASK
#define EFM_FLAG_CMD_FAIL      EFM_STS_FAIL_MASK
#define EFM_FLAG_CMD_IDLE      EFM_STS_IDLE_MASK

uint32_t EFM_GetStatusFlags(EFM_Type * base);
void EFM_ClearStatusFlags(EFM_Type * base, uint32_t flags);

uint32_t EFM_EraseBlock(EFM_Type * base, uint32_t * paddr);
uint32_t EFM_EraseSector(EFM_Type * base, uint32_t * paddr);
uint32_t EFM_Program(EFM_Type * base, uint32_t * paddr, const void * pdata);
void EFM_Flush(EFM_Type * base);

#endif /* __HAL_EFM_H__ */

